Docker dfimage工具从Docker镜像提取Dockerfile

dfimage 是什么

dfimage是一个用于从Docker镜像生成Dockerfile的工具。dfimage通过分析Docker镜像中的文件系统和元数据,自动生成Dockerfile文件。dfimage是一个开源的工具

dfimage 安装

下载dfimage镜像

1
docker pull alpine/dfimage

做别名

1
docker pull alpine/dfimage

dfimage 使用

自定义镜像生成Dockerfile

现有自定义镜像atlas-know:v1
原始的dockerfile 如下

1
2
3
4
5
6
7
8
9
10
[root@bogon zstp]# cat Dockerfile 
FROM java:8

ADD Atlas-know-0.0.1-SNAPSHOT.jar Atlas-know-0.0.1-SNAPSHOT.jar

COPY application.yml application.yml

EXPOSE 80

ENTRYPOINT ["java","-jar","Atlas-know-0.0.1-SNAPSHOT.jar"]

执行命令提取dockerfile

1
dfimage -sV=1.36 atlas-know:v1

输入如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[root@bogon ~]# dfimage -sV=1.36 atlas-know:v1
Analyzing atlas-know:v1
Docker Version: 20.10.17
GraphDriver: overlay2
Environment Variables
|PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|LANG=C.UTF-8
|JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
|JAVA_VERSION=8u111
|JAVA_DEBIAN_VERSION=8u111-b14-2~bpo8+1
|CA_CERTIFICATES_JAVA_VERSION=20140324

Open Ports
|80

Image user
|User is root

Potential secrets:
|Found match etc/ssh/ssh_config Client SSH Config .?ssh_config[\s\S]* 05251aa5c8cf9e8b8e56242302bb1c5173e306492933eddae0e35ea3da5476be/layer.tar
Dockerfile:
CMD ["/bin/bash"]
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl wget \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get install -y --no-install-recommends bzr git mercurial openssh-client subversion procps \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get install -y --no-install-recommends bzip2 unzip xz-utils \
&& rm -rf /var/lib/apt/lists/*
RUN echo 'deb http://deb.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list
ENV LANG=C.UTF-8
RUN { echo '#!/bin/sh'; echo 'set -e'; echo; echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; } > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ENV JAVA_VERSION=8u111
ENV JAVA_DEBIAN_VERSION=8u111-b14-2~bpo8+1
ENV CA_CERTIFICATES_JAVA_VERSION=20140324
RUN set -x \
&& apt-get update \
&& apt-get install -y openjdk-8-jdk="$JAVA_DEBIAN_VERSION" ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
&& rm -rf /var/lib/apt/lists/* \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
ADD file:93e69c0f737fd289e830ce5154cce963f7b84b1a2e43fe7f8dc1f552ecdd6bd4 in Atlas-know-0.0.1-SNAPSHOT.jar
Atlas-know-0.0.1-SNAPSHOT.jar

COPY file:39e47e887503d1fd0563a5e30ad7076e4884242f3b08c27964c2d527c0d0d1e8 in application.yml
application.yml

EXPOSE 80
ENTRYPOINT ["java" "-jar" "Atlas-know-0.0.1-SNAPSHOT.jar"]

一辈子很短,努力的做好两件事就好;
第一件事是热爱生活,好好的去爱身边的人;
第二件事是努力学习,在工作中取得不一样的成绩,实现自己的价值,而不是仅仅为了赚钱。

继开 wechat
欢迎加我的微信,共同交流技术